﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using DevExpress.Xpo;
using Component;

public partial class FrontEnd_Body_Center_SanPhamCungLoai : System.Web.UI.UserControl
{
    protected XPCollection<Product> _xpProduct = new XPCollection<Product>(KetNoiCSDL.session);
    protected string _Products = "";
    protected int _pagemax = 0;
    protected void Page_Load(object sender, EventArgs e)
    { 
        int idProduct = ConvertType.ToInt(QueryHelper.GetQueryString(Request, ConstString._id));
        _xpProduct = ProductDB.LayTatCaCacSPCungLoai(idProduct);
        foreach (Product pro in _xpProduct)
        {
            _Products += string.Format("{0},{1};", pro.Img, pro.UrlDetailFronent);
        }
        _Products = _Products.Substring(0, _Products.Length - 1);
        _Products += "";
        _pagemax = _xpProduct.Count % 4 == 0 ? (_xpProduct.Count / 4) : ((_xpProduct.Count / 4) + 1);
    }
    public string GetFourObj()
    {
        int dem = 0;
        string tam = "";
        foreach (Product pro in _xpProduct)
        {
            dem++;
            tam += "<a id=\"a" + dem.ToString() + "\" href=\"" + pro.UrlDetailFronent + "\">"
              + "  <img src=\"" + pro.Img + "\" border=\"none\" alt=\"" + Component.ProductDB.GetContentByLanguage(pro.Name, pro.NameEL) + "\" class=\"bg_cungloai\" /></a>";
            if (dem == 4) break;

        }
        return tam;
    }
}
